import { Boot } from '@wangeditor/editor'
import { WordPaster } from '../js/w'

export class WordPasterMenu {                       // JS 语法
    constructor() {
        this.title = 'Word一键粘贴' // 自定义菜单标题
        this.iconSvg = '<svg xmlns="http://www.w3.org/2000/svg" width="17.997" height="17.997" viewBox="0 0 256 256"><defs><style>.cls-word {fill: #2a5699;stroke: red;stroke-width: 0;fill-rule: evenodd;}</style></defs><path id="形状_322_1" data-name="形状 322 1" class="cls-word" d="M151.073,0V24l100.049,1c7.281,10.483,5,33.153,5,50.994,0,31.446,6.231,136.936-4,154.981-30.08,3.954-67.758,2.032-101.049,2v23c-33.11.582-59.279-7.066-87.042-13L0,231.972,1,23C53.016,21.061,95.8.421,151.073,0Zm0,33v21H227.11v11H151.073v16H227.11v11H151.073v15l76.037,1q-0.5,5.5-1,11H151.073v15H227.11q-0.5,6-1,12H151.073v15H227.11v11l-76.037,1v15H227.11v11H151.073v24H247.12V33H151.073ZM24.012,86.989L38.018,165.98l18.009,1,11.005-54.994h1l11.005,56.993H97.047q10-42.99,20.01-85.989v-1l-18.009,1-10,58.993h-1L77.037,83.99l-17.008,1L48.023,139.983h-1l-8-52.994H24.012Z"/></svg>' // 可选
        this.tag = 'button'
    }

    // 获取菜单执行时的 value ，用不到则返回空 字符串或 false
    getValue(editor) {                              // JS 语法
        return ' hello '
    }

    // 菜单是否需要激活（如选中加粗文本，“加粗”菜单会激活），用不到则返回 false
    isActive(editor) {                    // JS 语法
        return false
    }

    // 菜单是否需要禁用（如选中 H1 ，“引用”菜单被禁用），用不到则返回 false
    isDisabled(editor) {                     // JS 语法
        return false
    }

    // 点击菜单时触发的函数
    exec(editor, value) {                              // JS 语法
        if (this.isDisabled(editor)) return
        WordPaster.getInstance().SetEditor(editor).Paste();
    }
}
export const WordPasterConf = {
    key: 'wordpaster', // 定义 menu key ：要保证唯一、不重复（重要）
    factory() {
        return new WordPasterMenu() // 把 `YourMenuClass` 替换为你菜单的 class
    }
}